{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 作业"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 一、填空"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1 、None  \n",
    "## 2 、[3,4]     \n",
    "## 3 、3  \n",
    "## 4 、97"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 二、判断题"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、×\n",
    "## 2、×\n",
    "## 3、√\n",
    "## 4、×"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 三、编程题"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2、"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入字符串fasdfa\n"
     ]
    }
   ],
   "source": [
    "s= input(\"请输入字符串\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "s 2\n",
      "d 3\n"
     ]
    }
   ],
   "source": [
    "for i in range(len(s)):\n",
    "    if s[i] not in (s[:i] + s[i + 1:]):\n",
    "        print(s[i], i)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3、"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入字符串sdfghjk\n"
     ]
    }
   ],
   "source": [
    "s1= input('请输入字符串') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "zd = {}\n",
    "num=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in s1:\n",
    "    num += 1\n",
    "    zd.update({i: num})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'s': 1, 'd': 2, 'f': 3, 'g': 4, 'h': 5, 'j': 6, 'k': 7}\n",
      "[('s', 1), ('d', 2), ('f', 3), ('g', 4), ('h', 5), ('j', 6), ('k', 7)]\n"
     ]
    }
   ],
   "source": [
    "print(zd)\n",
    "a=list(zd.values())\n",
    "b=list(zd)\n",
    "c=list(zip(b,a))\n",
    "print(c)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 6、"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入字符串：10022001\n"
     ]
    }
   ],
   "source": [
    "str1 = list(input('请输入字符串：'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "i = 0\n",
    "a=b=0\n",
    "while i <= (len(str1)/2):\n",
    "    print(i)\n",
    "    if str1[i] == str1[-(i+1)]:\n",
    "        a=1\n",
    "        \n",
    "    else:\n",
    "        b=1\n",
    "    i+=1  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "改文字是回文\n"
     ]
    }
   ],
   "source": [
    "if(a+b == 2):\n",
    "    print('改文字不是回文')\n",
    "else:\n",
    "    print('改文字是回文')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'list'>\n"
     ]
    }
   ],
   "source": [
    "print(type(str1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 拓展题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "A =[]\n",
    "B =[]\n",
    "C =[]\n",
    "office = [A, B, C]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "names=['张伟','王伟','王芳','李伟','李娜','张敏','李静','王静','刘伟','王秀英']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in names:\n",
    "    a = random.randint(0,2)\n",
    "    if a == 0:\n",
    "        A.append(i)\n",
    "    elif a == 1:\n",
    "        B.append(i)\n",
    "    elif a == 2:\n",
    "        C.append(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "办公室1： ['王芳', '刘伟'] \n",
      "办公室2： ['张伟', '王伟', '张敏', '李静', '王秀英'] \n",
      "办公室3： ['李伟', '李娜', '王静']\n"
     ]
    }
   ],
   "source": [
    "print('办公室1：', A, \"\\n办公室2：\", B, \"\\n办公室3：\", C)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
